#include "parser.h"
#include "graph.h"
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

Graph &Parser::initGraphPara(Graph &M, int argc, char **argv) {
    while (true) {
        int option_index = 0;
        double db = 0;
        string key;

        int c = getopt_long(argc, argv, "", Parser::longOpts, &option_index);
        if (c == -1)
            break;
        switch (c) {
        case 0:
            sscanf(optarg, "%lf", &db);
            M.attr.insert(
                pair<string, double>(Parser::longOpts[option_index].name, db));
            break;
        case 1:
            key = Parser::longOpts[option_index].name;
            if (key == "network")
                M.network = optarg;
            else if (key == "dynamic")
                M.dynamic = optarg;
            else if (key == "output-type")
                M.output_type = optarg;
            else if (key == "info-level-meta")
                M.info_level_meta = optarg;
            else if (key == "info-level-temp")
                M.info_level_temp = optarg;
            else if (key == "enable-ABM")
                M.enable_ABM = optarg;
            break;
        case 2:
            cout << "network:网络类型" << endl;
            cout << "dynamic:动力学类型" << endl;
            cout << "node:节点数量" << endl;
            cout << "info-level-meta:"
                 << "指元信息等级：all全部normal有详细节点信息没有度信息degree"
                    "只有度分布信息"
                 << endl;
            cout << "info-level-temp:"
                 << "all所有信息sum只有总数none不输出当日信息" << endl;
            cout << "output-type:file或terminal" << endl;
            break;
        default:
            break;
        }
    }

    return M;
}
